package com.xmu.makerspace.controller;

import com.xmu.makerspace.domain.Seat;
import com.xmu.makerspace.model.seat.SeatVO;
import com.xmu.makerspace.model.seat.TeamVO;
import com.xmu.makerspace.service.SelectSeatService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jetbrains.annotations.NonNls;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by status200 on 2017/9/11.
 */
@RestController
@RequestMapping("api/select-seat")
public class SelectSeatApiController {

    @NonNls
    private static final Log log = LogFactory.getLog(SelectSeatApiController.class);

    @NonNls
    private final SelectSeatService selectSeatService;

    @Autowired
    public SelectSeatApiController(SelectSeatService selectSeatService) {
        this.selectSeatService = selectSeatService;
    }


    @GetMapping("all-seats-info")
    public List<SeatVO> allSeatsInfo(@RequestParam("roomNo") int roomNo) {
        return selectSeatService.getAllSeatsInfo(roomNo);
    }

    @GetMapping("all-team-without-seat")
    public List<TeamVO> allTeamWithoutSeat() {
        return selectSeatService.getAllTeamWithoutSeat();
    }

    @PostMapping("submit")
    public void submit(@RequestBody List<Seat> seats) {
        selectSeatService.submit(seats);
    }
}
